
package com.bangcommunity.bbframe.dynconfig.parser;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.Properties;

/**
 * Created by tanghc
 */
public abstract class PropertyValueParserUtil {

    protected final Logger logger = LoggerFactory.getLogger(this.getClass());


    public static Integer getIntValue(Properties properties, String key, Integer defaultValue) {
        ConfigValueParser<Integer> configValueParser = new IntConfigValueParser();
        return configValueParser.parse(properties, key, defaultValue);
    }

    public static Long getLongValue(Properties properties, String key, Long defaultValue) {
        ConfigValueParser<Long> configValueParser = new LongConfigValueParser();
        return configValueParser.parse(properties, key, defaultValue);
    }

    public static Float getFloatValue(Properties properties, String key, Float defaultValue) {
        ConfigValueParser<Float> configValueParser = new FloatConfigValueParser();
        return configValueParser.parse(properties, key, defaultValue);
    }

    public static Double getDoubleValue(Properties properties, String key, Double defaultValue) {
        ConfigValueParser<Double> configValueParser = new DoubleConfigValueParser();
        return configValueParser.parse(properties, key, defaultValue);
    }

    public static Boolean getBooleanValue(Properties properties, String key, Boolean defaultValue) {
        ConfigValueParser<Boolean> configValueParser = new BooleanConfigValueParser();
        return configValueParser.parse(properties, key, defaultValue);
    }

    public static Byte getByteValue(Properties properties, String key, Byte defaultValue) {
        ConfigValueParser<Byte> configValueParser = new ByteConfigValueParser();
        return configValueParser.parse(properties, key, defaultValue);
    }


    public static BigDecimal getBigDecimalValue(Properties properties, String key, BigDecimal defaultValue) {
        ConfigValueParser<BigDecimal> configValueParser = new BigDecimalConfigValueParser();
        return configValueParser.parse(properties, key, defaultValue);
    }

    public static String getValue(Properties properties, String key, String defaultValue) {
        ConfigValueParser<String> configValueParser = new StringConfigValueParser();
        return configValueParser.parse(properties, key, defaultValue);

    }

}
